home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / dev / gui / gtlayout.lha / Source / LT_HandleInput.c < prev    next >
C/C++ Source or Header  |  1999-01-02  |  49KB  |  2,234 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1999 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. /*****************************************************************************/
  15.  
  16. #include <clib/keymap_protos.h>
  17. #include <pragmas/keymap_pragmas.h>
  18.  
  19. /*****************************************************************************/
  20.  
  21. #include "Assert.h"
  22.  
  23. /*****************************************************************************/
  24.  
  25. STATIC LONG
  26. CurrentWrap(ObjectNode *Node,LONG Current)
  27. {
  28.     if(Current > Node->Max)
  29.         Current = Node->Min;
  30.     else
  31.     {
  32.         if(Current < Node->Min)
  33.             Current = Node->Max;
  34.     }
  35.  
  36.     return(Current);
  37. }
  38.  
  39. STATIC BOOL
  40. CurrentInBounds(ObjectNode *Node,LONG Current)
  41. {
  42.     return((BOOL)(Node->Min <= Current && Current <= Node->Max && Current != Node->Current));
  43. }
  44.  
  45. /****** gtlayout.library/LT_HandleInput ******************************************
  46. *
  47. *   NAME
  48. *    LT_HandleInput -- Filter IntuiMessage data.
  49. *
  50. *   SYNOPSIS
  51. *    LT_HandleInput(Handle,Qualifier,Class,Code,Gadget);
  52. *                     A0      D0      A1    A2    A3
  53. *
  54. *    VOID LT_HandleInput(LayoutHandle *,ULONG,ULONG *,
  55. *                        UWORD *,struct Gadget **);
  56. *
  57. *   FUNCTION
  58. *    In order to keep track of user interface actions, such as
  59. *    keys getting pressed, sliders getting moved, etc. your
  60. *    code is to call LT_HandleInput() with data copied from the
  61. *    IntuiMessage it has just received and replied.
  62. *
  63. *   INPUTS
  64. *    Handle - Pointer to a LayoutHandle structure.
  65. *
  66. *    Qualifier - The Qualifier value copied from the
  67. *        IntuiMessage structure.
  68. *
  69. *    Class - Pointer to the ULONG variable which holds the
  70. *        value copied from the Class entry of the
  71. *        IntuiMessage structure.
  72. *
  73. *    Code - Pointer to the UWORD variable which holds the
  74. *        value copied from the Code entry of the
  75. *        IntuiMessage structure.
  76. *
  77. *    Gadget - Pointer to the Gadget value copied from the
  78. *        IAddress entry of the IntuiMessage structure.
  79. *
  80. *   RESULT
  81. *    none
  82. *
  83. *   EXAMPLE
  84. *    struct IntuiMessage *IntuiMessage;
  85. *    ULONG Qualifier,Class;
  86. *    UWORD Code;
  87. *    struct Gadget *Gadget;
  88. *
  89. *    for(;;)
  90. *    {
  91. *        WaitPort(Window->UserPort);
  92. *
  93. *        while(IntuiMessage = GT_GetIMsg(Window->UserPort))
  94. *        {
  95. *            Class = IntuiMessage->Class;
  96. *            Code = IntuiMessage->Code;
  97. *            Qualifier = IntuiMessage->Qualifier;
  98. *            Gadget = IntuiMessage->Gadget;
  99. *
  100. *            GT_ReplyIMsg(IntuiMessage);
  101. *
  102. *            LT_HandleInput(Handle,Qualifier,&Class,&Code,&Gadget);
  103. *        }
  104. *    }
  105. *
  106. *   NOTES
  107. *    For BOOPSI_KIND objects keystroke activation may lead to
  108. *    unexpected results. Your application will hear a IDCMP_GADGETUP
  109. *    event, the IntuiMessage->Code value will hold the ANSI key
  110. *    code of the key the user pressed.
  111. *
  112. *    Do not call this routine before you have actually
  113. *    replied the IntuiMessage received or weird things
  114. *    may happen. This is not a suggestion, it's a threat.
  115. *
  116. ******************************************************************************
  117. *
  118. */
  119.  
  120. VOID LIBENT
  121. LT_HandleInput(REG(a0) LayoutHandle *Handle,REG(d0) ULONG MsgQualifier,REG(a1) ULONG *MsgClass,REG(a2) UWORD *MsgCode,REG(a3) struct Gadget **MsgGadget)
  122. {
  123.     ObjectNode *Node;
  124.     BOOL Activate;
  125.  
  126.     if(!Handle)
  127.         return;
  128.  
  129.     if(Handle->Failed)
  130.     {
  131.         *MsgClass = IDCMP_CLOSEWINDOW;
  132.  
  133.         if(!Handle->NeedDelay)
  134.             Handle->NeedDelay = TRUE;
  135.         else
  136.             LTP_Delay(0,500000);    // Give the guy a break
  137.  
  138.         return;
  139.     }
  140.  
  141.     Activate = FALSE;
  142.  
  143.     switch(*MsgClass)
  144.     {
  145.         case IDCMP_CHANGEWINDOW:
  146.  
  147.             if(!(Handle->Window->Flags & WFLG_SIZEGADGET) && (Handle->Window->Flags & WFLG_HASZOOM) && !V39)
  148.             {
  149.                 #ifdef DO_BOOPSI_KIND
  150.                 {
  151.                     if(Handle->BOOPSIList)
  152.                         RefreshGList((struct Gadget *)Handle->BOOPSIList,Handle->Window,NULL,(UWORD)-1);
  153.                 }
  154.                 #endif    /* DO_BOOPSI_KIND */
  155.  
  156.                 RefreshGList(Handle->List,Handle->Window,NULL,(UWORD)-1);
  157.  
  158.                 GT_RefreshWindow(Handle->Window,NULL);
  159.  
  160.                 LTP_DrawGroup(Handle,Handle->TopGroup);
  161.             }
  162.  
  163.             break;
  164.  
  165.         case IDCMP_NEWSIZE:
  166.  
  167.                 // Did the user cancel the resize operation?
  168.  
  169.             if(Handle->SizeVerified && Handle->SizeWidth == Handle->Window->Width && Handle->SizeHeight == Handle->Window->Height)
  170.             {
  171.                 Handle->SizeVerified    = FALSE;
  172.                 Handle->SizeWidth    = 0;
  173.                 Handle->SizeHeight    = 0;
  174.  
  175.                     // Put the gadgets back in
  176.  
  177.                 AddGList(Handle->Window,Handle->List,(UWORD)-1,(UWORD)-1,NULL);
  178.             }
  179.             else
  180.             {
  181.                 struct IBox Box;
  182.  
  183.                 Handle->SizeWidth    = 0;
  184.                 Handle->SizeHeight    = 0;
  185.  
  186.                 Box.Left    = 0;
  187.                 Box.Top        = 0;
  188.                 Box.Width    = Handle->Window->Width;
  189.                 Box.Height    = Handle->Window->Height;
  190.  
  191.                 LT_LockWindow(Handle->Window);
  192.  
  193.                 if((Handle->ResizeObject != NULL) && (Handle->ResizeObject->Type == LISTVIEW_KIND))
  194.                     Handle->ResizeObject->Special.List.IgnoreListContents = TRUE;
  195.  
  196.                 LT_RebuildTags(Handle,TRUE,
  197.                     LAWN_Bounds,    &Box,
  198.                 TAG_DONE);
  199.  
  200.                 LT_UnlockWindow(Handle->Window);
  201.  
  202.                 if(Handle->Failed)
  203.                     *MsgClass = IDCMP_CLOSEWINDOW;
  204.                 else
  205.                     *MsgClass = NULL;
  206.             }
  207.  
  208.             break;
  209.  
  210.         case IDCMP_REFRESHWINDOW:
  211.  
  212.             if(Handle->AutoRefresh)
  213.             {
  214.                 LT_BeginRefresh(Handle);
  215.  
  216.                 LT_EndRefresh(Handle,TRUE);
  217.  
  218.                 *MsgClass = NULL;
  219.             }
  220.  
  221.             break;
  222.  
  223.         case IDCMP_INTUITICKS:
  224.  
  225.             if(Handle->ActiveIncrementer)
  226.             {
  227.                 if(Handle->IncrementerCountdown > 0)
  228.                     Handle->IncrementerCountdown--;
  229.  
  230.                 if(Handle->IncrementerCountdown <= 0)
  231.                 {
  232.                     if(Handle->ActiveIncrementer->Host->Flags & GFLG_SELECTED)
  233.                     {
  234.                         if(Handle->ActiveIncrementer->Type == TAPEDECK_KIND)
  235.                         {
  236.                             *MsgClass    = IDCMP_GADGETUP;
  237.                             *MsgCode    = 0;
  238.                             *MsgGadget    = Handle->ActiveIncrementer->Host;
  239.                         }
  240.                         else
  241.                         {
  242.                             ObjectNode *Parent;
  243.                             LONG Number;
  244.  
  245.                             if(Handle->IncrementerAccelerate > 0 && !(MsgQualifier & (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT)))
  246.                                 Handle->IncrementerAccelerate--;
  247.  
  248.                             if(Handle->IncrementerAccelerate <= 0)
  249.                             {
  250.                                 Handle->IncrementerAccelerate = 10;
  251.  
  252.                                 Handle->IncrementerIncrement *= 2;
  253.                             }
  254.  
  255.                             *MsgClass    = IDCMP_GADGETUP;
  256.                             *MsgCode    = 0;
  257.                             *MsgGadget    = Handle->ActiveIncrementer->Special.Incrementer.Parent;
  258.  
  259.                             Parent = (*MsgGadget)->UserData;
  260.  
  261.                             if(Parent->Type == FRACTION_KIND)
  262.                             {
  263.                                 STRPTR String;
  264.  
  265.                                 String = (STRPTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE);
  266.  
  267.                                 if(CallHookPkt(Parent->Special.String.IncrementerHook,(APTR)String,Handle->ActiveIncrementer->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT))
  268.                                 {
  269.                                     LT_SetAttributes(Handle,Parent->ID,
  270.                                         GTST_String,String,
  271.                                     TAG_DONE);
  272.                                 }
  273.                             }
  274.                             else
  275.                             {
  276.                                 if(Parent->Special.Integer.IncrementerHook)
  277.                                     Number = CallHookPkt(Parent->Special.Integer.IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE),Handle->ActiveIncrementer->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
  278.                                 else
  279.                                     Number = ((LONG)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE)) + Handle->ActiveIncrementer->Special.Incrementer.Amount * Handle->IncrementerIncrement;
  280.  
  281.                                 if(Number < Parent->Min)
  282.                                     Number = Parent->Min;
  283.                                 else
  284.                                 {
  285.                                     if(Number > Parent->Max)
  286.                                         Number = Parent->Max;
  287.                                 }
  288.  
  289.                                 LT_SetAttributes(Handle,Parent->ID,
  290.                                     LAPR_Object,    Parent,
  291.                                     GTIN_Number,    Number,
  292.                                 TAG_DONE);
  293.                             }
  294.                         }
  295.                     }
  296.                     else
  297.                     {
  298.                         Handle->IncrementerIncrement    = 1;
  299.                         Handle->IncrementerAccelerate    = 10;
  300.                     }
  301.  
  302.                     if(Handle->IncrementerIncrement == 1)
  303.                         Handle->IncrementerCountdown = 2;
  304.                 }
  305.             }
  306.  
  307.             break;
  308.  
  309.         case IDCMP_RAWKEY:
  310.         {
  311.             UBYTE Buffer[10];
  312.             LONG Key;
  313.             struct InputEvent event;
  314.             BOOL KeyUp;
  315.  
  316.             if((*MsgCode & ~IECODE_UP_PREFIX) == 95 && Handle->HelpHook)
  317.             {
  318.                 if(!(*MsgCode & IECODE_UP_PREFIX))
  319.                 {
  320.                     ObjectNode *Item;
  321.                     struct HelpMsg Message;
  322.                     struct IBox Box;
  323.  
  324.                     Item = LTP_FindNode_Position(Handle->TopGroup,Handle->Window->MouseX,Handle->Window->MouseY);
  325.  
  326.                     if(Item == Handle->TopGroup)
  327.                     {
  328.                         if(Item->ID <= PHANTOM_GROUP_ID)
  329.                             Item = NULL;
  330.                     }
  331.  
  332.                     if(Item)
  333.                     {
  334.                         Message.ObjectID = Item->ID;
  335.  
  336.                         Box.Left    = Item->Left;
  337.                         Box.Top        = Item->Top;
  338.                         Box.Width    = Item->Width;
  339.                         Box.Height    = Item->Height;
  340.                     }
  341.                     else
  342.                     {
  343.                         Message.ObjectID = -1;
  344.  
  345.                         Box.Left    = 0;
  346.                         Box.Top        = 0;
  347.                         Box.Width    = Handle->Window->Width;
  348.                         Box.Height    = Handle->Window->Height;
  349.                     }
  350.  
  351.                     Message.Handle = Handle;
  352.  
  353.                     CallHookPkt(Handle->HelpHook,&Message,&Box);
  354.                 }
  355.  
  356.                 if(Handle->RawKeyFilter)
  357.                     *MsgClass = NULL;
  358.  
  359.                 break;
  360.             }
  361.  
  362.             if((*MsgCode >= 99 && *MsgCode <= 103) || *MsgCode == 96 || *MsgCode == 97)
  363.             {
  364.                 if(Handle->RawKeyFilter)
  365.                     *MsgClass = NULL;
  366.  
  367.                 break;
  368.             }
  369.  
  370.             event.ie_NextEvent            = NULL;
  371.             event.ie_Code                 = (*MsgCode) & ~IECODE_UP_PREFIX;
  372.             event.ie_Qualifier            = MsgQualifier & ~QUALIFIER_SHIFT;
  373.             event.ie_Class                = IECLASS_RAWKEY;
  374.             event.ie_SubClass            = 0;
  375.             event.ie_position.ie_addr    = (APTR)*MsgGadget;
  376.  
  377.             Buffer[0] = 0;
  378.  
  379.             if(MapRawKey(&event,Buffer,9,NULL) < 1)
  380.             {
  381.                 if(Handle->RawKeyFilter)
  382.                     *MsgClass = NULL;
  383.  
  384.                 break;
  385.             }
  386.  
  387.             if(!(Key = Buffer[0]))
  388.             {
  389.                 if(Handle->RawKeyFilter)
  390.                     *MsgClass = NULL;
  391.  
  392.                 break;
  393.             }
  394.  
  395.             if((*MsgCode) & IECODE_UP_PREFIX)
  396.                 KeyUp = TRUE;
  397.             else
  398.                 KeyUp = FALSE;
  399.  
  400.             if(!KeyUp && Handle->CursorKey && (*MsgCode == CURSORUP || *MsgCode == CURSORDOWN))
  401.             {
  402.                 ObjectNode *Node;
  403.                 struct Gadget *Gadget;
  404.                 LONG NewState;
  405.                 LONG CurrentTop = 0;    /* For the sake of the compiler, initialize this */
  406.  
  407.                 Handle->ClickSeconds = Handle->ClickMicros = 0;
  408.  
  409.                 Node        = Handle->CursorKey;
  410.                 Gadget        = Node->Host;
  411.                 NewState    = Node->Current;
  412.  
  413.                 if(V39)
  414.                 {
  415.                     GT_GetGadgetAttrs(Gadget,Handle->Window,NULL,
  416.                         GTLV_Top,&CurrentTop,
  417.                     TAG_DONE);
  418.                 }
  419.  
  420.                 if(*MsgCode == CURSORDOWN)
  421.                 {
  422.                     if(MsgQualifier & QUALIFIER_SHIFT)
  423.                     {
  424.                         if(V39)
  425.                         {
  426.                             if(NewState != CurrentTop + Node->Lines - 1)
  427.                                 NewState = CurrentTop + Node->Lines - 1;
  428.                             else
  429.                                 NewState += Node->Lines;
  430.                         }
  431.                         else
  432.                             NewState += Node->Lines;
  433.                     }
  434.                     else
  435.                     {
  436.                         if(MsgQualifier & (QUALIFIER_ALT | QUALIFIER_CONTROL))
  437.                             NewState = Node->Max;
  438.                         else
  439.                             NewState++;
  440.                     }
  441.                 }
  442.                 else
  443.                 {
  444.                     if(MsgQualifier & QUALIFIER_SHIFT)
  445.                     {
  446.                         if(V39)
  447.                         {
  448.                             if(NewState != CurrentTop)
  449.                                 NewState = CurrentTop;
  450.                             else
  451.                                 NewState -= Node->Lines;
  452.                         }
  453.                         else
  454.                             NewState -= Node->Lines;
  455.                     }
  456.                     else
  457.                     {
  458.                         if(MsgQualifier & (QUALIFIER_ALT | QUALIFIER_CONTROL))
  459.                             NewState = Node->Min;
  460.                         else
  461.                             NewState--;
  462.                     }
  463.                 }
  464.  
  465.                 if(NewState < Node->Min)
  466.                     NewState = Node->Min;
  467.                 else
  468.                 {
  469.                     if(NewState > Node->Max)
  470.                         NewState = Node->Max;
  471.                 }
  472.  
  473.                 if(NewState != Node->Current || Node->Max == Node->Min)
  474.                 {
  475.                     ULONG WhichTag;
  476.  
  477.                     if(V39)
  478.                         WhichTag = GTLV_MakeVisible;
  479.                     else
  480.                         WhichTag = GTLV_Top;
  481.  
  482.                     GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  483.                         WhichTag,    Node->Current = NewState,
  484.                         Node->Special.List.LinkID != -1 ? GTLV_Selected : TAG_IGNORE,Node->Current,
  485.                     TAG_DONE);
  486.  
  487.                     LTP_PutStorage(Node);
  488.  
  489.                     *MsgClass    = IDCMP_GADGETUP;
  490.                     *MsgCode    = Node->Current;
  491.                     *MsgGadget    = Gadget;
  492.  
  493.                     if(Node->Special.List.AutoPageID != -1)
  494.                         *MsgClass = NULL;
  495.  
  496.                     if(!LTP_NotifyPager(Handle,Node->Special.List.AutoPageID,Node->Current))
  497.                         *MsgClass = IDCMP_CLOSEWINDOW;
  498.                 }
  499.                 else
  500.                 {
  501.                     if(Handle->RawKeyFilter)
  502.                         *MsgClass = NULL;
  503.                 }
  504.  
  505.                 Handle->ActiveFrame = NULL;
  506.  
  507.                 return;
  508.             }
  509.  
  510.             if(Key == '\t' && !KeyUp)
  511.             {
  512.                 ObjectNode *Node;
  513.  
  514.                 if(Handle->RawKeyFilter)
  515.                     *MsgClass = NULL;
  516.  
  517.                 if(Node = Handle->TabKey)
  518.                 {
  519.                     if(!(Node->Disabled))
  520.                     {
  521.                         LONG Choice;
  522.  
  523.                         if(MsgQualifier & QUALIFIER_SHIFT)
  524.                             Choice = Node->Current - 1;
  525.                         else
  526.                             Choice = Node->Current + 1;
  527.  
  528.                         Choice = CurrentWrap(Node,Choice);
  529.  
  530.                         if(Choice != Node->Current)
  531.                         {
  532.                             LONG AutoPageID = -1,Type = 0;/* For the sake of the compiler, initialize this */
  533.                             BOOL CanBlink = FALSE;
  534.  
  535.                             *MsgClass = IDCMP_GADGETUP;
  536.  
  537.                             switch(Node->Type)
  538.                             {
  539.                                 case CYCLE_KIND:
  540.  
  541.                                     AutoPageID    = Node->Special.Cycle.AutoPageID;
  542.                                     Type        = GTCY_Active;
  543.                                     CanBlink    = TRUE;
  544.                                     break;
  545.  
  546.                                 #ifdef DO_POPUP_KIND
  547.                                 {
  548.                                     case POPUP_KIND:
  549.  
  550.                                         AutoPageID    = Node->Special.Popup.AutoPageID;
  551.                                         Type        = LAPU_Active;
  552.                                         CanBlink    = TRUE;
  553.                                         break;
  554.                                 }
  555.                                 #endif
  556.  
  557.                                 #ifdef DO_TAB_KIND
  558.                                 {
  559.                                     case TAB_KIND:
  560.  
  561.                                         AutoPageID    = Node->Special.Tab.AutoPageID;
  562.                                         Type        = LATB_Active;
  563.                                         break;
  564.                                 }
  565.                                 #endif
  566.  
  567.                                 case MX_KIND:
  568.  
  569.                                     AutoPageID    = Node->Special.Radio.AutoPageID;
  570.                                     Type        = GTMX_Active;
  571.  
  572.                                     *MsgClass = IDCMP_GADGETDOWN;
  573.  
  574.                                     break;
  575.                             }
  576.  
  577.                             *MsgCode    = (UWORD)Choice;
  578.                             *MsgGadget    = Node->Host;
  579.  
  580.                             if(CanBlink)
  581.                                 LTP_BlinkButton(Handle,*MsgGadget);
  582.  
  583.                             LT_SetAttributes(Handle,Node->ID,
  584.                                 Type,Choice,
  585.                             TAG_DONE);
  586.  
  587.                             if(AutoPageID != -1)
  588.                                 *MsgClass = NULL;
  589.  
  590.                             if(!LTP_NotifyPager(Handle,AutoPageID,Choice))
  591.                                 *MsgClass = IDCMP_CLOSEWINDOW;
  592.                         }
  593.                     }
  594.                 }
  595.  
  596.                 Handle->ActiveFrame = NULL;
  597.  
  598.                 return;
  599.             }
  600.  
  601.             if(Key == '\33' && !KeyUp)
  602.             {
  603.                 ObjectNode *Node;
  604.  
  605.                 Handle->ClickSeconds = Handle->ClickMicros = 0;
  606.  
  607.                 if(Node = Handle->EscKey)
  608.                 {
  609.                     if(!Node->Disabled)
  610.                     {
  611.                         LTP_BlinkButton(Handle,Node->Host);
  612.  
  613.                         *MsgCode    = 0;
  614.                         *MsgGadget    = Node->Host;
  615.                         *MsgClass    = IDCMP_GADGETUP;
  616.                     }
  617.                     else
  618.                     {
  619.                         if(Handle->RawKeyFilter)
  620.                             *MsgClass = NULL;
  621.                     }
  622.                 }
  623.                 else
  624.                 {
  625.                     if(Handle->Window->Flags & WFLG_CLOSEGADGET)
  626.                     {
  627.                         *MsgCode    = 0;
  628.                         *MsgGadget    = NULL;
  629.                         *MsgClass    = IDCMP_CLOSEWINDOW;
  630.                     }
  631.                     else
  632.                     {
  633.                         if(Handle->RawKeyFilter)
  634.                             *MsgClass = NULL;
  635.                     }
  636.                 }
  637.  
  638.                 Handle->ActiveFrame = NULL;
  639.  
  640.                 return;
  641.             }
  642.             else
  643.             {
  644.                 struct Gadget *Gadget;
  645.                 ObjectNode *Node;
  646.                 BOOL FoundIt,Forward,Swallow;
  647.                 LONG NewValue;
  648.                 LONG i;
  649.  
  650.                 if(Handle->ReturnKey && Key == '\r')
  651.                 {
  652.                     Node = Handle->ReturnKey;
  653.  
  654.                     if(!KeyUp && !Node->Disabled)
  655.                     {
  656.                         LTP_BlinkButton(Handle,Node->Host);
  657.  
  658.                         *MsgClass    = IDCMP_GADGETUP;
  659.                         *MsgCode    = 0;
  660.                         *MsgGadget    = Node->Host;
  661.                     }
  662.                     else
  663.                     {
  664.                         if(Handle->RawKeyFilter)
  665.                             *MsgClass = NULL;
  666.                     }
  667.  
  668.                     Handle->ClickSeconds = Handle->ClickMicros = 0;
  669.  
  670.                     Handle->ActiveFrame = NULL;
  671.  
  672.                     return;
  673.                 }
  674.  
  675.                 if(MsgQualifier & QUALIFIER_SHIFT)
  676.                     Forward = FALSE;
  677.                 else
  678.                     Forward = TRUE;
  679.  
  680.                 FoundIt = FALSE;
  681.  
  682.                 for(i = 0 ; !FoundIt && i < Handle->Count ; i++)
  683.                 {
  684.                     if(Gadget = Handle->GadgetArray[i])
  685.                     {
  686.                         if(GETOBJECT(Gadget,Node))
  687.                         {
  688.                             if(Key == Node->Key)
  689.                             {
  690.                                 if(Node->Disabled)
  691.                                     break;
  692.                                 else
  693.                                 {
  694.                                     Swallow = FALSE;
  695.  
  696.                                     NewValue = Node->Current;
  697.  
  698.                                     switch(Node->Type)
  699.                                     {
  700.                                         #ifdef DO_BOOPSI_KIND
  701.                                         {
  702.                                             case BOOPSI_KIND:
  703.  
  704.                                                 if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  705.                                                 {
  706.                                                     if(Node->Special.BOOPSI.ActivateHook)
  707.                                                     {
  708.                                                         if(CallHookPkt(Node->Special.BOOPSI.ActivateHook,(APTR)Handle,(APTR)Node->Host))
  709.                                                         {
  710.                                                             Swallow = TRUE;
  711.                                                             break;
  712.                                                         }
  713.                                                     }
  714.  
  715.                                                     *MsgClass    = IDCMP_GADGETUP;
  716.                                                     *MsgCode    = Forward ? 1 : (UWORD)-1;
  717.                                                     *MsgGadget    = Gadget;
  718.                                                 }
  719.                                                 else
  720.                                                     Swallow = TRUE;
  721.  
  722.                                                 break;
  723.                                         }
  724.                                         #endif    /* DO_BOOPSI_KIND */
  725.  
  726.                                         #ifdef DO_POPUP_KIND
  727.                                         {
  728.                                             case POPUP_KIND:
  729.  
  730.                                                 if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  731.                                                 {
  732.                                                     if(Forward)
  733.                                                         NewValue++;
  734.                                                     else
  735.                                                         NewValue--;
  736.  
  737.                                                     NewValue = CurrentWrap(Node,NewValue);
  738.  
  739.                                                     LTP_BlinkButton(Handle,Node->Host);
  740.  
  741.                                                     LT_SetAttributes(Handle,0,
  742.                                                         LAPR_Gadget,    Node->Host,
  743.                                                         LAPU_Active,    NewValue,
  744.                                                     TAG_DONE);
  745.  
  746.                                                     *MsgClass    = IDCMP_GADGETUP;
  747.                                                     *MsgCode    = Node->Current;
  748.                                                     *MsgGadget    = Node->Host;
  749.                                                 }
  750.                                                 else
  751.                                                     Swallow = TRUE;
  752.  
  753.                                                 break;
  754.                                         }
  755.                                         #endif    // DO_POPUP_KIND
  756.  
  757.                                         #ifdef DO_TAB_KIND
  758.                                         {
  759.                                             case TAB_KIND:
  760.  
  761.                                                 if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  762.                                                 {
  763.                                                     if(Forward)
  764.                                                         NewValue++;
  765.                                                     else
  766.                                                         NewValue--;
  767.  
  768.                                                     NewValue = CurrentWrap(Node,NewValue);
  769.  
  770.                                                     LT_SetAttributes(Handle,0,
  771.                                                         LAPR_Gadget,    Node->Host,
  772.                                                         LAPU_Active,    NewValue,
  773.                                                     TAG_DONE);
  774.  
  775.                                                     *MsgClass    = IDCMP_GADGETUP;
  776.                                                     *MsgCode    = Node->Current;
  777.                                                     *MsgGadget    = Node->Host;
  778.                                                 }
  779.                                                 else
  780.                                                     Swallow = TRUE;
  781.  
  782.                                                 break;
  783.                                         }
  784.                                         #endif    // DO_TAB_KIND
  785.  
  786.                                         #ifdef DO_TAPEDECK_KIND
  787.                                         {
  788.                                             case TAPEDECK_KIND:
  789.  
  790.                                                 if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  791.                                                 {
  792.                                                     if(Node->Special.TapeDeck.Toggle)
  793.                                                     {
  794.                                                         LT_SetAttributes(Handle,Node->ID,
  795.                                                             LAPR_Object,    Node,
  796.                                                             LATD_Pressed,    !Node->Current,
  797.                                                         TAG_DONE);
  798.                                                     }
  799.                                                     else
  800.                                                         LTP_BlinkButton(Handle,Gadget);
  801.  
  802.                                                     if(Gadget->Flags & GFLG_SELECTED)
  803.                                                         *MsgCode = TRUE;
  804.                                                     else
  805.                                                         *MsgCode = FALSE;
  806.  
  807.                                                     *MsgClass    = IDCMP_GADGETUP;
  808.                                                     *MsgGadget    = Gadget;
  809.                                                 }
  810.                                                 else
  811.                                                     Swallow = TRUE;
  812.  
  813.                                                 break;
  814.                                         }
  815.                                         #endif    /* DO_TAPEDECK_KIND */
  816.  
  817.                                         case CHECKBOX_KIND:
  818.  
  819.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  820.                                             {
  821.                                                 Node->Current = !Node->Current;
  822.  
  823.                                                 LTP_PutStorage(Node);
  824.  
  825.                                                 GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  826.                                                     GTCB_Checked,Node->Current,
  827.                                                 TAG_DONE);
  828.  
  829.                                                 *MsgClass    = IDCMP_GADGETUP;
  830.                                                 *MsgCode    = Node->Current;
  831.                                                 *MsgGadget    = Gadget;
  832.                                             }
  833.                                             else
  834.                                                 Swallow = TRUE;
  835.  
  836.                                             FoundIt = TRUE;
  837.  
  838.                                             break;
  839.  
  840.                                         case LISTVIEW_KIND:
  841.  
  842.                                             if(!KeyUp)
  843.                                             {
  844.                                                 if(NewValue == -1)
  845.                                                 {
  846.                                                     if(Node->Min != -1)
  847.                                                     {
  848.                                                         if(Forward)
  849.                                                             NewValue = Node->Min;
  850.                                                         else
  851.                                                             NewValue = Node->Max;
  852.                                                     }
  853.                                                 }
  854.                                                 else
  855.                                                 {
  856.                                                     if(Forward)
  857.                                                         NewValue++;
  858.                                                     else
  859.                                                         NewValue--;
  860.                                                 }
  861.  
  862.                                                 if(CurrentInBounds(Node,NewValue))
  863.                                                 {
  864.                                                     ULONG WhichTag;
  865.  
  866.                                                     if(V39)
  867.                                                         WhichTag = GTLV_MakeVisible;
  868.                                                     else
  869.                                                         WhichTag = GTLV_Top;
  870.  
  871.                                                     GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  872.                                                         WhichTag,Node->Current = NewValue,
  873.                                                         Node->Special.List.LinkID != -1 ? GTLV_Selected : TAG_IGNORE,Node->Current,
  874.                                                     TAG_DONE);
  875.  
  876.                                                     LTP_PutStorage(Node);
  877.  
  878.                                                     *MsgClass    = IDCMP_GADGETUP;
  879.                                                     *MsgCode    = Node->Current;
  880.                                                     *MsgGadget    = Gadget;
  881.  
  882.                                                     if(Node->Special.List.AutoPageID != -1)
  883.                                                     {
  884.                                                         *MsgClass = NULL;
  885.  
  886.                                                         if(!LTP_NotifyPager(Handle,Node->Special.List.AutoPageID,Node->Current))
  887.                                                             *MsgClass = IDCMP_CLOSEWINDOW;
  888.                                                     }
  889.                                                 }
  890.                                                 else
  891.                                                     Swallow = TRUE;
  892.                                             }
  893.                                             else
  894.                                                 Swallow = TRUE;
  895.  
  896.                                             FoundIt = TRUE;
  897.  
  898.                                             break;
  899.  
  900.                                         case MX_KIND:
  901.  
  902.                                             if(!KeyUp)
  903.                                             {
  904.                                                 if(Forward)
  905.                                                     NewValue++;
  906.                                                 else
  907.                                                     NewValue--;
  908.  
  909.                                                 if(CurrentInBounds(Node,NewValue))
  910.                                                 {
  911.                                                     GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  912.                                                         GTMX_Active,Node->Current = NewValue,
  913.                                                     TAG_DONE);
  914.  
  915.                                                     LTP_PutStorage(Node);
  916.  
  917.                                                     *MsgClass    = IDCMP_GADGETDOWN;
  918.                                                     *MsgCode    = Node->Current;
  919.                                                     *MsgGadget    = Gadget;
  920.  
  921.                                                     if(Node->Special.Radio.AutoPageID != -1)
  922.                                                     {
  923.                                                         *MsgClass = NULL;
  924.  
  925.                                                         if(!LTP_NotifyPager(Handle,Node->Special.Radio.AutoPageID,Node->Current))
  926.                                                             *MsgClass = IDCMP_CLOSEWINDOW;
  927.                                                     }
  928.                                                 }
  929.                                                 else
  930.                                                     Swallow = TRUE;
  931.                                             }
  932.                                             else
  933.                                                 Swallow = TRUE;
  934.  
  935.                                             FoundIt = TRUE;
  936.  
  937.                                             break;
  938.  
  939.                                         case TEXT_KIND:
  940.  
  941.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  942.                                             {
  943.                                                 if(Node->Special.Text.Picker)
  944.                                                 {
  945.                                                     LTP_BlinkButton(Handle,Node->Special.Text.Picker);
  946.  
  947.                                                     *MsgClass    = IDCMP_IDCMPUPDATE;
  948.                                                     *MsgCode    = 0;
  949.                                                     *MsgGadget    = Gadget;
  950.                                                 }
  951.                                                 else
  952.                                                     Swallow = TRUE;
  953.                                             }
  954.                                             else
  955.                                                 Swallow = TRUE;
  956.  
  957.                                             FoundIt = TRUE;
  958.  
  959.                                             break;
  960.  
  961.                                         case NUMBER_KIND:
  962.  
  963.                                             Swallow = TRUE;
  964.                                             FoundIt = TRUE;
  965.  
  966.                                             break;
  967.  
  968.                                         case CYCLE_KIND:
  969.  
  970.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  971.                                             {
  972.                                                 if(Forward)
  973.                                                     NewValue++;
  974.                                                 else
  975.                                                     NewValue--;
  976.  
  977.                                                 NewValue = CurrentWrap(Node,NewValue);
  978.  
  979.                                                 LTP_BlinkButton(Handle,Gadget);
  980.  
  981.                                                 GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  982.                                                     GTCY_Active,Node->Current = NewValue,
  983.                                                 TAG_DONE);
  984.  
  985.                                                 LTP_PutStorage(Node);
  986.  
  987.                                                 *MsgClass    = IDCMP_GADGETUP;
  988.                                                 *MsgCode    = Node->Current;
  989.                                                 *MsgGadget    = Gadget;
  990.  
  991.                                                 if(Node->Special.Cycle.AutoPageID != -1)
  992.                                                 {
  993.                                                     *MsgClass = NULL;
  994.  
  995.                                                     if(!LTP_NotifyPager(Handle,Node->Special.Cycle.AutoPageID,Node->Current))
  996.                                                         *MsgClass = IDCMP_CLOSEWINDOW;
  997.                                                 }
  998.                                             }
  999.                                             else
  1000.                                                 Swallow = TRUE;
  1001.  
  1002.                                             FoundIt = TRUE;
  1003.  
  1004.                                             break;
  1005.  
  1006.                                         case PALETTE_KIND:
  1007.  
  1008.                                             if(!KeyUp)
  1009.                                             {
  1010.                                                 if(Node->Special.Palette.UsePicker)
  1011.                                                 {
  1012.                                                     if(!(MsgQualifier & IEQUALIFIER_REPEAT))
  1013.                                                     {
  1014.                                                         LTP_BlinkButton(Handle,Node->Special.Palette.Picker);
  1015.  
  1016.                                                         *MsgClass    = IDCMP_IDCMPUPDATE;
  1017.                                                         *MsgCode    = 0;
  1018.                                                         *MsgGadget    = Gadget;
  1019.                                                     }
  1020.                                                     else
  1021.                                                         Swallow = TRUE;
  1022.  
  1023.                                                     FoundIt = TRUE;
  1024.  
  1025.                                                     break;
  1026.                                                 }
  1027.  
  1028.                                                 if(Node->Special.Palette.TranslateBack)
  1029.                                                 {
  1030.                                                     LONG Index = Node->Special.Palette.TranslateBack[Node->Current];
  1031.  
  1032.                                                     if(Index < Node->Min)
  1033.                                                         Index = Node->Min;
  1034.                                                     else
  1035.                                                     {
  1036.                                                         if(Index > Node->Max)
  1037.                                                             Index = Node->Max;
  1038.                                                     }
  1039.  
  1040.                                                     if(Forward)
  1041.                                                         Index++;
  1042.                                                     else
  1043.                                                         Index--;
  1044.  
  1045.                                                     if(Index < Node->Min)
  1046.                                                         Index = Node->Min;
  1047.                                                     else
  1048.                                                     {
  1049.                                                         if(Index > Node->Max)
  1050.                                                             Index = Node->Max;
  1051.                                                     }
  1052.  
  1053.                                                     NewValue = Node->Special.Palette.ColourTable[Index];
  1054.                                                 }
  1055.                                                 else
  1056.                                                 {
  1057.                                                     if(Forward)
  1058.                                                         NewValue++;
  1059.                                                     else
  1060.                                                         NewValue--;
  1061.                                                 }
  1062.  
  1063.                                                 if(CurrentInBounds(Node,NewValue))
  1064.                                                 {
  1065.                                                     GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  1066.                                                         GTPA_Color,Node->Current = NewValue,
  1067.                                                     TAG_DONE);
  1068.  
  1069.                                                     LTP_PutStorage(Node);
  1070.  
  1071.                                                     *MsgClass    = IDCMP_GADGETUP;
  1072.                                                     *MsgCode    = Node->Current;
  1073.                                                     *MsgGadget    = Gadget;
  1074.                                                 }
  1075.                                                 else
  1076.                                                     Swallow = TRUE;
  1077.                                             }
  1078.                                             else
  1079.                                                 Swallow = TRUE;
  1080.  
  1081.                                             FoundIt = TRUE;
  1082.  
  1083.                                             break;
  1084.  
  1085.                                         case SLIDER_KIND:
  1086.  
  1087.                                             if(KeyUp)
  1088.                                             {
  1089.                                                 *MsgClass    = IDCMP_GADGETUP;
  1090.                                                 *MsgCode    = Node->Current;
  1091.                                                 *MsgGadget    = Gadget;
  1092.                                             }
  1093.                                             else
  1094.                                             {
  1095.                                                 if(Forward)
  1096.                                                     NewValue++;
  1097.                                                 else
  1098.                                                     NewValue--;
  1099.  
  1100.                                                 if(CurrentInBounds(Node,NewValue))
  1101.                                                 {
  1102.                                                     GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  1103.                                                         GTSL_Level,Node->Current = NewValue,
  1104.                                                     TAG_DONE);
  1105.  
  1106.                                                     LTP_PutStorage(Node);
  1107.  
  1108.                                                     *MsgClass    = IDCMP_MOUSEMOVE;
  1109.                                                     *MsgCode    = Node->Current;
  1110.                                                     *MsgGadget    = Gadget;
  1111.                                                 }
  1112.                                                 else
  1113.                                                     Swallow = TRUE;
  1114.                                             }
  1115.  
  1116.                                             FoundIt = TRUE;
  1117.  
  1118.                                             break;
  1119.  
  1120.                                         #ifdef DO_LEVEL_KIND
  1121.                                         {
  1122.                                             case LEVEL_KIND:
  1123.  
  1124.                                                 if(KeyUp)
  1125.                                                 {
  1126.                                                     *MsgClass    = IDCMP_GADGETUP;
  1127.                                                     *MsgCode    = Node->Current;
  1128.                                                     *MsgGadget    = Gadget;
  1129.  
  1130.                                                     LTP_PutStorage(Node);
  1131.  
  1132.                                                     LTP_LevelGadgetDrawLabel(Handle,Node,FALSE);
  1133.                                                 }
  1134.                                                 else
  1135.                                                 {
  1136.                                                     if(Forward)
  1137.                                                         NewValue++;
  1138.                                                     else
  1139.                                                         NewValue--;
  1140.  
  1141.                                                     if(CurrentInBounds(Node,NewValue))
  1142.                                                     {
  1143.                                                         LT_SetAttributes(Handle,Node->ID,
  1144.                                                             LAPR_Object,    Node,
  1145.                                                             LAVL_Level,        NewValue,
  1146.                                                         TAG_DONE);
  1147.  
  1148.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  1149.                                                         *MsgCode    = NewValue;
  1150.                                                         *MsgGadget    = Gadget;
  1151.  
  1152.                                                         LTP_LevelGadgetDrawLabel(Handle,Node,FALSE);
  1153.                                                     }
  1154.                                                     else
  1155.                                                         Swallow = TRUE;
  1156.                                                 }
  1157.  
  1158.                                                 FoundIt = TRUE;
  1159.  
  1160.                                                 break;
  1161.                                         }
  1162.                                         #endif    /* DO_LEVEL_KIND */
  1163.  
  1164.                                         case SCROLLER_KIND:
  1165.  
  1166.                                             if(KeyUp)
  1167.                                             {
  1168.                                                 *MsgClass    = IDCMP_GADGETUP;
  1169.                                                 *MsgCode    = Node->Current;
  1170.                                                 *MsgGadget    = Gadget;
  1171.                                             }
  1172.                                             else
  1173.                                             {
  1174.                                                 if(Forward)
  1175.                                                     NewValue++;
  1176.                                                 else
  1177.                                                     NewValue--;
  1178.  
  1179.                                                 if(CurrentInBounds(Node,NewValue))
  1180.                                                 {
  1181.                                                     GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  1182.                                                         GTSC_Top,Node->Current = NewValue,
  1183.                                                     TAG_DONE);
  1184.  
  1185.                                                     LTP_PutStorage(Node);
  1186.  
  1187.                                                     *MsgClass    = IDCMP_MOUSEMOVE;
  1188.                                                     *MsgCode    = Node->Current;
  1189.                                                     *MsgGadget    = Gadget;
  1190.                                                 }
  1191.                                                 else
  1192.                                                     Swallow = TRUE;
  1193.                                             }
  1194.  
  1195.                                             FoundIt = TRUE;
  1196.  
  1197.                                             break;
  1198.  
  1199.                                         case STRING_KIND:
  1200.                                         case PASSWORD_KIND:
  1201.  
  1202.                                             if(!KeyUp)
  1203.                                             {
  1204.                                                 if(Node->Special.String.Picker && !Forward)
  1205.                                                 {
  1206.                                                     LTP_BlinkButton(Handle,Node->Special.String.Picker);
  1207.  
  1208.                                                     *MsgClass    = IDCMP_IDCMPUPDATE;
  1209.                                                     *MsgCode    = 0;
  1210.                                                     *MsgGadget    = Gadget;
  1211.                                                 }
  1212.                                                 else
  1213.                                                 {
  1214.                                                     ActivateGadget(Gadget,Handle->Window,NULL);
  1215.  
  1216.                                                     *MsgClass    = IDCMP_GADGETDOWN;
  1217.                                                     *MsgCode    = 0;
  1218.                                                     *MsgGadget    = Gadget;
  1219.  
  1220.                                                     Handle->Previous = Gadget;
  1221.                                                 }
  1222.                                             }
  1223.                                             else
  1224.                                                 Swallow = TRUE;
  1225.  
  1226.                                             FoundIt = TRUE;
  1227.  
  1228.                                             break;
  1229.  
  1230.                                         #ifdef DO_TEXTEDIT_KIND
  1231.                                         {
  1232.                                             case TEXTEDIT_KIND:
  1233.  
  1234.                                                 if(NOT KeyUp)
  1235.                                                 {
  1236.                                                     ActivateGadget(Gadget,Handle->Window,NULL);
  1237.  
  1238.                                                     (*MsgClass)        = IDCMP_GADGETDOWN;
  1239.                                                     (*MsgCode)        = 0;
  1240.                                                     (*MsgGadget)    = Gadget;
  1241.  
  1242.                                                     Handle->Previous = Gadget;
  1243.                                                 }
  1244.                                                 else
  1245.                                                 {
  1246.                                                     Swallow = TRUE;
  1247.                                                 }
  1248.  
  1249.                                                 FoundIt = TRUE;
  1250.  
  1251.                                                 break;
  1252.                                         }
  1253.                                         #endif /* DO_TEXTEDIT_KIND */
  1254.  
  1255.                                         case FRACTION_KIND:
  1256.  
  1257.                                             if(!KeyUp)
  1258.                                             {
  1259.                                                 if(Node->Special.String.IncrementerHook)
  1260.                                                 {
  1261.                                                     ObjectNode *incNode,*Parent;
  1262.                                                     struct Gadget *Incrementer;
  1263.                                                     STRPTR String;
  1264.  
  1265.                                                     Parent = (ObjectNode *)Gadget->UserData;
  1266.  
  1267.                                                     if(Forward)
  1268.                                                     {
  1269.                                                         incNode = Node->Special.String.RightIncrementer->UserData;
  1270.  
  1271.                                                         Incrementer = Node->Special.String.RightIncrementer;
  1272.                                                     }
  1273.                                                     else
  1274.                                                     {
  1275.                                                         incNode = Node->Special.String.LeftIncrementer->UserData;
  1276.  
  1277.                                                         Incrementer = Node->Special.String.LeftIncrementer;
  1278.                                                     }
  1279.  
  1280.                                                     String = (STRPTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE);
  1281.  
  1282.                                                     if(CallHookPkt(Parent->Special.String.IncrementerHook,(APTR)String,incNode->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT))
  1283.                                                     {
  1284.                                                         LTP_BlinkButton(Handle,Incrementer);
  1285.  
  1286.                                                         LT_SetAttributes(Handle,Parent->ID,
  1287.                                                             GTST_String,String,
  1288.                                                         TAG_DONE);
  1289.  
  1290.                                                         *MsgClass = IDCMP_GADGETUP;
  1291.                                                     }
  1292.                                                 }
  1293.                                                 else
  1294.                                                 {
  1295.                                                     ActivateGadget(Gadget,Handle->Window,NULL);
  1296.  
  1297.                                                     *MsgClass = IDCMP_GADGETDOWN;
  1298.                                                 }
  1299.  
  1300.                                                 *MsgCode    = 0;
  1301.                                                 *MsgGadget    = Gadget;
  1302.  
  1303.                                                 Handle->Previous = Gadget;
  1304.                                             }
  1305.                                             else
  1306.                                                 Swallow = TRUE;
  1307.  
  1308.                                             FoundIt = TRUE;
  1309.  
  1310.                                             break;
  1311.  
  1312.                                         case INTEGER_KIND:
  1313.  
  1314.                                             if(!KeyUp)
  1315.                                             {
  1316.                                                 if(Node->Special.Integer.UseIncrementers)
  1317.                                                 {
  1318.                                                     ObjectNode *incNode,*Parent;
  1319.                                                     struct Gadget *Incrementer;
  1320.                                                     LONG Number;
  1321.  
  1322.                                                     Parent = (ObjectNode *)Gadget->UserData;
  1323.  
  1324.                                                     if(Forward)
  1325.                                                     {
  1326.                                                         incNode = Node->Special.Integer.RightIncrementer->UserData;
  1327.  
  1328.                                                         Incrementer = Node->Special.Integer.RightIncrementer;
  1329.                                                     }
  1330.                                                     else
  1331.                                                     {
  1332.                                                         incNode = Node->Special.Integer.LeftIncrementer->UserData;
  1333.  
  1334.                                                         Incrementer = Node->Special.Integer.LeftIncrementer;
  1335.                                                     }
  1336.  
  1337.                                                     if(Parent->Special.Integer.IncrementerHook)
  1338.                                                         Number = CallHookPkt(Parent->Special.Integer.IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE),incNode->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
  1339.                                                     else
  1340.                                                         Number = ((LONG)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE)) + incNode->Special.Incrementer.Amount;
  1341.  
  1342.                                                     if(Node->Min <= Number && Number <= Node->Max && Number != Parent->Special.Integer.Number)
  1343.                                                     {
  1344.                                                         LTP_BlinkButton(Handle,Incrementer);
  1345.  
  1346.                                                         LT_SetAttributes(Handle,Parent->ID,
  1347.                                                             LAPR_Object,    Parent,
  1348.                                                             GTIN_Number,    Number,
  1349.                                                         TAG_DONE);
  1350.  
  1351.                                                         *MsgClass = IDCMP_GADGETUP;
  1352.                                                     }
  1353.                                                 }
  1354.                                                 else
  1355.                                                 {
  1356.                                                     ActivateGadget(Gadget,Handle->Window,NULL);
  1357.  
  1358.                                                     *MsgClass = IDCMP_GADGETDOWN;
  1359.                                                 }
  1360.  
  1361.                                                 *MsgCode    = 0;
  1362.                                                 *MsgGadget    = Gadget;
  1363.  
  1364.                                                 Handle->Previous = Gadget;
  1365.                                             }
  1366.                                             else
  1367.                                                 Swallow = TRUE;
  1368.  
  1369.                                             FoundIt = TRUE;
  1370.  
  1371.                                             break;
  1372.  
  1373.                                         case BUTTON_KIND:
  1374.  
  1375.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  1376.                                             {
  1377.                                                 LTP_BlinkButton(Handle,Gadget);
  1378.  
  1379.                                                 *MsgClass    = IDCMP_GADGETUP;
  1380.                                                 *MsgCode    = 0;
  1381.                                                 *MsgGadget    = Gadget;
  1382.                                             }
  1383.                                             else
  1384.                                                 Swallow = TRUE;
  1385.  
  1386.                                             FoundIt = TRUE;
  1387.  
  1388.                                             break;
  1389.                                     }
  1390.  
  1391.                                     if(Swallow)
  1392.                                     {
  1393.                                         if(Handle->RawKeyFilter)
  1394.                                             *MsgClass = NULL;
  1395.                                     }
  1396.                                 }
  1397.                             }
  1398.                         }
  1399.                     }
  1400.                 }
  1401.  
  1402.                 if(FoundIt)
  1403.                     Handle->ClickSeconds = Handle->ClickMicros = 0;
  1404.             }
  1405.  
  1406.             Handle->ActiveFrame = NULL;
  1407.  
  1408.             break;
  1409.         }
  1410.  
  1411.         case IDCMP_GADGETDOWN:
  1412.  
  1413.             if(GETOBJECT((*MsgGadget),Node))
  1414.             {
  1415.                 if(Node->Type != LISTVIEW_KIND)
  1416.                     Handle->ClickSeconds = Handle->ClickMicros = 0;
  1417.  
  1418.                 Handle->ActiveFrame = NULL;
  1419.  
  1420.                 switch(Node->Type)
  1421.                 {
  1422.                     #ifdef DO_LEVEL_KIND
  1423.                     {
  1424.                         case LEVEL_KIND:
  1425.  
  1426.                             Handle->CurrentLevel = Node;
  1427.  
  1428.                             Node->Current = LTP_GetCurrentLevel(Node);
  1429.  
  1430.                             *MsgCode = Node->Current;
  1431.  
  1432.                             LTP_LevelGadgetDrawLabel(Handle,Node,FALSE);
  1433.  
  1434.                             break;
  1435.                     }
  1436.                     #endif    /* DO_LEVEL_KIND */
  1437.  
  1438.                     #ifdef DO_TEXTEDIT_KIND
  1439.                     {
  1440.                         case TEXTEDIT_KIND:
  1441.  
  1442.                             Handle->Previous = (*MsgGadget);
  1443.                             break;
  1444.                     }
  1445.                     #endif /* DO_TEXTEDIT_KIND */
  1446.  
  1447.                     case STRING_KIND:
  1448.                     case FRACTION_KIND:
  1449.                     case INTEGER_KIND:
  1450.                     case PASSWORD_KIND:
  1451.  
  1452.                         Handle->Previous = *MsgGadget;
  1453.                         break;
  1454.  
  1455.                     #ifdef DO_TAPEDECK_KIND
  1456.                     {
  1457.                         case TAPEDECK_KIND:
  1458.  
  1459.                             if(Node->Special.TapeDeck.Tick)
  1460.                             {
  1461.                                 Handle->ActiveIncrementer        = Node;
  1462.                                 Handle->IncrementerCountdown    = 2;
  1463.                                 Handle->IncrementerAccelerate    = 10;
  1464.                                 Handle->IncrementerIncrement    = 1;
  1465.  
  1466.                                 *MsgClass    = IDCMP_GADGETUP;
  1467.                                 *MsgCode    = 0;
  1468.                             }
  1469.                             else
  1470.                             {
  1471.                                 if(Node->Special.TapeDeck.Toggle)
  1472.                                 {
  1473.                                     if((*MsgGadget)->Flags & GFLG_SELECTED)
  1474.                                         *MsgCode = TRUE;
  1475.                                     else
  1476.                                         *MsgCode = FALSE;
  1477.  
  1478.                                     Node->Current = *MsgCode;
  1479.  
  1480.                                     LTP_PutStorage(Node);
  1481.  
  1482.                                     if(Handle->Previous && !Node->PageSelector)
  1483.                                         Activate = TRUE;
  1484.  
  1485.                                     *MsgClass = IDCMP_GADGETUP;
  1486.                                 }
  1487.                             }
  1488.  
  1489.                             break;
  1490.                     }
  1491.                     #endif    /* DO_TAPEDECK_KIND */
  1492.  
  1493.                     case MX_KIND:
  1494.  
  1495.                         if(!V39 && Node->Disabled)
  1496.                         {
  1497.                             GT_SetGadgetAttrs(*MsgGadget,Handle->Window,NULL,
  1498.                                 GTMX_Active,Node->Current,
  1499.                             TAG_DONE);
  1500.  
  1501.                             *MsgClass = NULL;
  1502.                         }
  1503.                         else
  1504.                         {
  1505.                             Node->Current = *MsgCode;
  1506.  
  1507.                             LTP_PutStorage(Node);
  1508.  
  1509.                             if(Node->Special.Radio.AutoPageID != -1)
  1510.                             {
  1511.                                 *MsgClass = NULL;
  1512.  
  1513.                                 if(!LTP_NotifyPager(Handle,Node->Special.Radio.AutoPageID,Node->Current))
  1514.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1515.                             }
  1516.  
  1517.                             if(Handle->Previous && !Node->PageSelector)
  1518.                                 Activate = TRUE;
  1519.                         }
  1520.  
  1521.                         break;
  1522.  
  1523.                     case SLIDER_KIND:
  1524.  
  1525.                         if(Node->Min < 0)
  1526.                             Node->Current = (WORD)*MsgCode;
  1527.                         else
  1528.                             Node->Current = *MsgCode;
  1529.  
  1530.                         LTP_PutStorage(Node);
  1531.  
  1532.                         if(Handle->Previous && !Node->PageSelector)
  1533.                             Activate = TRUE;
  1534.  
  1535.                         break;
  1536.  
  1537.                     case SCROLLER_KIND:
  1538.  
  1539.                         Node->Current = *MsgCode;
  1540.  
  1541.                         LTP_PutStorage(Node);
  1542.  
  1543.                         if(Handle->Previous && !Node->PageSelector)
  1544.                             Activate = TRUE;
  1545.  
  1546.                         break;
  1547.  
  1548.                     case INCREMENTER_KIND:
  1549.  
  1550.                         Handle->ActiveIncrementer        = Node;
  1551.                         Handle->IncrementerCountdown    = 6;
  1552.                         Handle->IncrementerAccelerate    = 10;
  1553.                         Handle->IncrementerIncrement    = 1;
  1554.  
  1555.                         *MsgClass    = IDCMP_GADGETUP;
  1556.                         *MsgCode    = 0;
  1557.                         *MsgGadget    = Node->Special.Incrementer.Parent;
  1558.  
  1559.                         /* ALWAYS */
  1560.                         {
  1561.                             struct ObjectNode *Parent;
  1562.                             LONG Number;
  1563.  
  1564.                             Parent = (ObjectNode *)(*MsgGadget)->UserData;
  1565.  
  1566.                             if(Parent->Type == FRACTION_KIND)
  1567.                             {
  1568.                                 STRPTR String;
  1569.  
  1570.                                 String = (STRPTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE);
  1571.  
  1572.                                 if(CallHookPkt(Parent->Special.String.IncrementerHook,(APTR)String,Node->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT))
  1573.                                 {
  1574.                                     LT_SetAttributes(Handle,Parent->ID,
  1575.                                         GTST_String,String,
  1576.                                     TAG_DONE);
  1577.                                 }
  1578.                             }
  1579.                             else
  1580.                             {
  1581.                                 if(Parent->Special.Integer.IncrementerHook)
  1582.                                     Number = CallHookPkt(Parent->Special.Integer.IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE),Node->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
  1583.                                 else
  1584.                                     Number = LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE) + Node->Special.Incrementer.Amount;
  1585.  
  1586.                                 if(Number >= Parent->Min && Number <= Parent->Max)
  1587.                                     LT_SetAttributes(Handle,Parent->ID,LAPR_Object,Parent,GTIN_Number,Number,TAG_DONE);
  1588.                                 else
  1589.                                     *MsgClass = NULL;
  1590.                             }
  1591.                         }
  1592.  
  1593.                         break;
  1594.                 }
  1595.             }
  1596.  
  1597.             break;
  1598.  
  1599.         case IDCMP_MOUSEBUTTONS:
  1600.         {
  1601.             ObjectNode *Node;
  1602.             LONG x,y;
  1603.  
  1604.             x = Handle->Window->MouseX;
  1605.             y = Handle->Window->MouseY;
  1606.  
  1607.             Node = LTP_FindNode_Position(Handle->TopGroup,x,y);
  1608.  
  1609.             if(((*MsgCode) & IECODE_UP_PREFIX) && Handle->Previous)
  1610.                 Activate = TRUE;
  1611.  
  1612.             if(Node && !Node->Disabled)
  1613.             {
  1614.                 if(*MsgCode == SELECTDOWN)
  1615.                 {
  1616.                     switch(Node->Type)
  1617.                     {
  1618.                         case CHECKBOX_KIND:
  1619.  
  1620.                             Node->Current = !Node->Current;
  1621.  
  1622.                             LTP_PutStorage(Node);
  1623.  
  1624.                             GT_SetGadgetAttrs(Node->Host,Handle->Window,NULL,
  1625.                                 GTCB_Checked,Node->Current,
  1626.                             TAG_DONE);
  1627.  
  1628.                             *MsgClass    = IDCMP_GADGETUP;
  1629.                             *MsgCode    = Node->Current;
  1630.                             *MsgGadget    = Node->Host;
  1631.  
  1632.                             break;
  1633.  
  1634.                         case MX_KIND:
  1635.                         {
  1636.                             LONG Index = LTP_Find_Clicked_Item(Handle,Node,x,y);
  1637.  
  1638.                             if(Index != -1)
  1639.                             {
  1640.                                 Node->Current = Index;
  1641.  
  1642.                                 GT_SetGadgetAttrs(Node->Host,Handle->Window,NULL,
  1643.                                     GTMX_Active,Index,
  1644.                                 TAG_DONE);
  1645.  
  1646.                                 LTP_PutStorage(Node);
  1647.  
  1648.                                 *MsgClass    = IDCMP_GADGETDOWN;
  1649.                                 *MsgCode    = Index;
  1650.                                 *MsgGadget    = Node->Host;
  1651.  
  1652.                                 if(Node->Special.Cycle.AutoPageID != -1)
  1653.                                     *MsgClass = NULL;
  1654.  
  1655.                                 if(!LTP_NotifyPager(Handle,Node->Special.Cycle.AutoPageID,Node->Current))
  1656.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1657.                             }
  1658.  
  1659.                             break;
  1660.                         }
  1661.  
  1662.                         case FRAME_KIND:
  1663.  
  1664.                             if(Node->Special.Frame.GenerateEvents)
  1665.                             {
  1666.                                 if(Node->Special.Frame.DrawBox)
  1667.                                 {
  1668.                                     if(x < Node->Left + 2 || x >= Node->Left + Node->Width - 2 || y < Node->Top + 1 || y >= Node->Top + Node->Height - 2)
  1669.                                         break;
  1670.                                 }
  1671.  
  1672.                                 *MsgClass    = IDCMP_GADGETDOWN;
  1673.                                 *MsgGadget    = &Node->Special.Frame.Dummy;
  1674.  
  1675.                                 Handle->ActiveFrame = Node;
  1676.                             }
  1677.  
  1678.                             break;
  1679.                     }
  1680.                 }
  1681.  
  1682.                 if(*MsgCode == SELECTUP)
  1683.                 {
  1684.                         // Now this is a real kludge; as of v37 the
  1685.                         // MX_KIND labels are not part of the gadget
  1686.                         // itself and a plain SELECTDOWN mouse event
  1687.                         // is sent as soon as the user clicks on it.
  1688.                         // This changed with v39 which presumably had
  1689.                         // some code in there to map mouse clicks on
  1690.                         // the gadget labels to proper buttonpress
  1691.                         // events. Now, try as you might the click is
  1692.                         // swallowed and we have to do with the
  1693.                         // SELECTUP, sigh...
  1694.  
  1695.                     if(V39 && Node->Type == MX_KIND)
  1696.                     {
  1697.                         LONG Index;
  1698.  
  1699.                         Index = LTP_Find_Clicked_Item(Handle,Node,x,y);
  1700.  
  1701.                         if(Index != -1)
  1702.                         {
  1703.                             GT_SetGadgetAttrs(Node->Host,Handle->Window,NULL,
  1704.                                 GTMX_Active,Index,
  1705.                             TAG_DONE);
  1706.  
  1707.                             Node->Current = Index;
  1708.  
  1709.                             LTP_PutStorage(Node);
  1710.  
  1711.                             *MsgClass    = IDCMP_GADGETDOWN;
  1712.                             *MsgCode    = Index;
  1713.                             *MsgGadget    = Node->Host;
  1714.  
  1715.                             if(Node->Special.Cycle.AutoPageID != -1)
  1716.                                 *MsgClass = NULL;
  1717.  
  1718.                             if(!LTP_NotifyPager(Handle,Node->Special.Cycle.AutoPageID,Node->Current))
  1719.                                 *MsgClass = IDCMP_CLOSEWINDOW;
  1720.                         }
  1721.                     }
  1722.  
  1723.                     if(Handle->ActiveIncrementer)
  1724.                     {
  1725.                         if(Handle->ActiveIncrementer->Type == TAPEDECK_KIND && Handle->ActiveIncrementer ->Special.TapeDeck.Tick)
  1726.                         {
  1727.                             Handle->ActiveIncrementer = NULL;
  1728.  
  1729.                             *MsgClass    = IDCMP_GADGETUP;
  1730.                             *MsgCode    = 1;
  1731.                         }
  1732.                         else
  1733.                         {
  1734.                             if(((ObjectNode *)Handle->ActiveIncrementer->Special.Incrementer.Parent->UserData)->Type == INTEGER_KIND)
  1735.                             {
  1736.                                 *MsgGadget    = Handle->ActiveIncrementer->Special.Incrementer.Parent;
  1737.                                 *MsgClass    = IDCMP_GADGETUP;
  1738.                                 *MsgCode    = 1;
  1739.                             }
  1740.  
  1741.                             Handle->ActiveIncrementer = NULL;
  1742.                         }
  1743.                     }
  1744.  
  1745.                     if(Handle->ActiveFrame)
  1746.                     {
  1747.                         *MsgClass    = IDCMP_GADGETUP;
  1748.                         *MsgGadget    = &Node->Special.Frame.Dummy;
  1749.  
  1750.                         Handle->ActiveFrame = NULL;
  1751.                     }
  1752.                 }
  1753.             }
  1754.  
  1755.             break;
  1756.         }
  1757.  
  1758.         case IDCMP_GADGETUP:
  1759.  
  1760.             #ifdef DO_LEVEL_KIND
  1761.             {
  1762.                 Handle->CurrentLevel = NULL;
  1763.             }
  1764.             #endif    /* DO_LEVEL_KIND */
  1765.  
  1766.             Handle->ActiveFrame = NULL;
  1767.  
  1768.             if(GETOBJECT((*MsgGadget),Node))
  1769.             {
  1770.                 if(Node->Type != LISTVIEW_KIND)
  1771.                     Handle->ClickSeconds = Handle->ClickMicros = 0;
  1772.  
  1773.                 switch(Node->Type)
  1774.                 {
  1775.                     case PASSWORD_KIND:
  1776.                     case STRING_KIND:
  1777.                     case FRACTION_KIND:
  1778.  
  1779.                         LTP_PutStorage(Node);
  1780.  
  1781.                         if(*MsgCode == 0x5F && Handle->HelpHook)
  1782.                         {
  1783.                             struct HelpMsg Message;
  1784.                             struct IBox Box;
  1785.  
  1786.                             Message.ObjectID = Node->ID;
  1787.  
  1788.                             Box.Left    = Node->Left;
  1789.                             Box.Top        = Node->Top;
  1790.                             Box.Width    = Node->Width;
  1791.                             Box.Height    = Node->Height;
  1792.  
  1793.                             Message.Handle = Handle;
  1794.  
  1795.                             CallHookPkt(Handle->HelpHook,&Message,&Box);
  1796.  
  1797.                             *MsgClass = NULL;
  1798.                         }
  1799.                         else
  1800.                             Handle->Previous = NULL;
  1801.  
  1802.                         break;
  1803.  
  1804.                     #ifdef DO_TEXTEDIT_KIND
  1805.                     {
  1806.                         case TEXTEDIT_KIND:
  1807.  
  1808.                             LTP_PutStorage(Node);
  1809.                             Handle->Previous = NULL;
  1810.                             break;
  1811.                     }
  1812.                     #endif /* DO_TEXTEDIT_KIND */
  1813.  
  1814.                     case INTEGER_KIND:
  1815.                     {
  1816.                         struct StringInfo *StringInfo = (struct StringInfo *)(*MsgGadget)->SpecialInfo;
  1817.                         LONG Contents = StringInfo->LongInt;
  1818.  
  1819.                         if(Contents < Node->Min)
  1820.                             Contents = Node->Min;
  1821.                         else
  1822.                         {
  1823.                             if(Contents > Node->Max)
  1824.                                 Contents = Node->Max;
  1825.                         }
  1826.  
  1827.                         LT_SetAttributes(Handle,(*MsgGadget)->GadgetID,GTIN_Number,Contents,TAG_DONE);
  1828.  
  1829.                         LTP_PutStorage(Node);
  1830.  
  1831.                         if(*MsgCode == 0x5F && Handle->HelpHook)
  1832.                         {
  1833.                             struct HelpMsg Message;
  1834.                             struct IBox Box;
  1835.  
  1836.                             Message.ObjectID = Node->ID;
  1837.  
  1838.                             Box.Left    = Node->Left;
  1839.                             Box.Top        = Node->Top;
  1840.                             Box.Width    = Node->Width;
  1841.                             Box.Height    = Node->Height;
  1842.  
  1843.                             Message.Handle = Handle;
  1844.  
  1845.                             CallHookPkt(Handle->HelpHook,&Message,&Box);
  1846.  
  1847.                             *MsgClass = NULL;
  1848.                         }
  1849.                         else
  1850.                             Handle->Previous = NULL;
  1851.  
  1852.                         break;
  1853.                     }
  1854.  
  1855.                     case CHECKBOX_KIND:
  1856.  
  1857.                         if(!V39)
  1858.                         {
  1859.                             if((*MsgGadget)->Flags & GFLG_SELECTED)
  1860.                                 *MsgCode = TRUE;
  1861.                             else
  1862.                                 *MsgCode = FALSE;
  1863.                         }
  1864.  
  1865.                         Node->Current = *MsgCode;
  1866.  
  1867.                         LTP_PutStorage(Node);
  1868.  
  1869.                         if(Handle->Previous && !Node->PageSelector)
  1870.                             Activate = TRUE;
  1871.  
  1872.                         break;
  1873.  
  1874.                     #ifdef DO_TAPEDECK_KIND
  1875.                     {
  1876.                         case TAPEDECK_KIND:
  1877.  
  1878.                             if(Node->Special.TapeDeck.Tick)
  1879.                             {
  1880.                                 Handle->ActiveIncrementer = NULL;
  1881.  
  1882.                                 *MsgClass    = IDCMP_GADGETUP;
  1883.                                 *MsgCode    = 1;
  1884.                             }
  1885.                             else
  1886.                             {
  1887.                                 if(Node->Special.TapeDeck.Toggle)
  1888.                                 {
  1889.                                     if((*MsgGadget)->Flags & GFLG_SELECTED)
  1890.                                         *MsgCode = TRUE;
  1891.                                     else
  1892.                                         *MsgCode = FALSE;
  1893.  
  1894.                                     Node->Current = *MsgCode;
  1895.  
  1896.                                     LTP_PutStorage(Node);
  1897.                                 }
  1898.                             }
  1899.  
  1900.                             if(Handle->Previous && !Node->PageSelector)
  1901.                                 Activate = TRUE;
  1902.  
  1903.                             break;
  1904.                     }
  1905.                     #endif    /* DO_TAPEDECK_KIND */
  1906.  
  1907.                     #ifdef DO_POPUP_KIND
  1908.                     {
  1909.                         case POPUP_KIND:
  1910.  
  1911.                             Node->Current = *MsgCode;
  1912.  
  1913.                             LTP_PutStorage(Node);
  1914.  
  1915.                             if(Handle->Previous && !Node->PageSelector)
  1916.                                 Activate = TRUE;
  1917.  
  1918.                             if(Node->Special.Popup.AutoPageID != -1)
  1919.                             {
  1920.                                 *MsgClass = NULL;
  1921.  
  1922.                                 if(!LTP_NotifyPager(Handle,Node->Special.Popup.AutoPageID,Node->Current))
  1923.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1924.                             }
  1925.  
  1926.                             break;
  1927.                     }
  1928.                     #endif
  1929.  
  1930.                     #ifdef DO_TAB_KIND
  1931.                     {
  1932.                         case TAB_KIND:
  1933.  
  1934.                             Node->Current = *MsgCode;
  1935.  
  1936.                             LTP_PutStorage(Node);
  1937.  
  1938.                             if(Handle->Previous && !Node->PageSelector)
  1939.                                 Activate = TRUE;
  1940.  
  1941.                             if(Node->Special.Tab.AutoPageID != -1)
  1942.                             {
  1943.                                 *MsgClass = NULL;
  1944.  
  1945.                                 if(!LTP_NotifyPager(Handle,Node->Special.Tab.AutoPageID,Node->Current))
  1946.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1947.                             }
  1948.  
  1949.                             break;
  1950.                     }
  1951.                     #endif
  1952.  
  1953.                     case CYCLE_KIND:
  1954.  
  1955.                         Node->Current = *MsgCode;
  1956.  
  1957.                         LTP_PutStorage(Node);
  1958.  
  1959.                         if(Handle->Previous && !Node->PageSelector)
  1960.                             Activate = TRUE;
  1961.  
  1962.                         if(Node->Special.Cycle.AutoPageID != -1)
  1963.                         {
  1964.                             *MsgClass = NULL;
  1965.  
  1966.                             if(!LTP_NotifyPager(Handle,Node->Special.Cycle.AutoPageID,Node->Current))
  1967.                                 *MsgClass = IDCMP_CLOSEWINDOW;
  1968.                         }
  1969.  
  1970.                         break;
  1971.  
  1972.                     case PALETTE_KIND:
  1973.  
  1974.                         Node->Current = *MsgCode;
  1975.  
  1976.                         LTP_PutStorage(Node);
  1977.  
  1978.                         if(Handle->Previous && !Node->PageSelector)
  1979.                             Activate = TRUE;
  1980.  
  1981.                         break;
  1982.  
  1983.                     case MX_KIND:
  1984.  
  1985.                         if(!V39 && Node->Disabled)
  1986.                         {
  1987.                             GT_SetGadgetAttrs(*MsgGadget,Handle->Window,NULL,
  1988.                                 GTMX_Active,Node->Current,
  1989.                             TAG_DONE);
  1990.  
  1991.                             *MsgClass = NULL;
  1992.                         }
  1993.                         else
  1994.                         {
  1995.                             Node->Current = *MsgCode;
  1996.  
  1997.                             LTP_PutStorage(Node);
  1998.  
  1999.                             if(Node->Special.Radio.AutoPageID != -1)
  2000.                             {
  2001.                                 *MsgClass = NULL;
  2002.  
  2003.                                 if(!LTP_NotifyPager(Handle,Node->Special.Radio.AutoPageID,Node->Current))
  2004.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  2005.                             }
  2006.  
  2007.                             if(Handle->Previous && !Node->PageSelector)
  2008.                                 Activate = TRUE;
  2009.                         }
  2010.  
  2011.                         break;
  2012.  
  2013.                     case SLIDER_KIND:
  2014.  
  2015.                         if(Node->Min < 0)
  2016.                             Node->Current = (WORD)*MsgCode;
  2017.                         else
  2018.                             Node->Current = *MsgCode;
  2019.  
  2020.                         LTP_PutStorage(Node);
  2021.  
  2022.                         if(Handle->Previous && !Node->PageSelector)
  2023.                             Activate = TRUE;
  2024.  
  2025.                         break;
  2026.  
  2027.                     #ifdef DO_LEVEL_KIND
  2028.                     {
  2029.                         case LEVEL_KIND:
  2030.  
  2031.                             Node->Current = LTP_GetCurrentLevel(Node);
  2032.  
  2033.                             *MsgCode    = Node->Current;
  2034.                             *MsgGadget    = Node->Host;
  2035.  
  2036.                             LTP_PutStorage(Node);
  2037.  
  2038.                             LTP_LevelGadgetDrawLabel(Handle,Node,FALSE);
  2039.  
  2040.                             break;
  2041.                     }
  2042.                     #endif    /* DO_LEVEL_KIND */
  2043.  
  2044.                     case SCROLLER_KIND:
  2045.  
  2046.                         Node->Current = *MsgCode;
  2047.  
  2048.                         LTP_PutStorage(Node);
  2049.  
  2050.                         if(Handle->Previous && !Node->PageSelector)
  2051.                             Activate = TRUE;
  2052.  
  2053.                         break;
  2054.  
  2055.                     case PICKER_KIND:
  2056.  
  2057.                         *MsgClass    = IDCMP_IDCMPUPDATE;
  2058.                         *MsgCode    = 0;
  2059.                         *MsgGadget    = Node->Special.Picker.Parent;
  2060.  
  2061.                         if(Handle->Previous && !Node->PageSelector)
  2062.                             Activate = TRUE;
  2063.  
  2064.                         break;
  2065.  
  2066.                     case INCREMENTER_KIND:
  2067.  
  2068.                         if(((ObjectNode *)Handle->ActiveIncrementer->Special.Incrementer.Parent->UserData)->Type == INTEGER_KIND)
  2069.                         {
  2070.                             *MsgGadget    = Handle->ActiveIncrementer->Special.Incrementer.Parent;
  2071.                             *MsgClass    = IDCMP_GADGETUP;
  2072.                             *MsgCode    = 1;
  2073.                         }
  2074.  
  2075.                         Handle->ActiveIncrementer = NULL;
  2076.                         break;
  2077.  
  2078.                     case LISTVIEW_KIND:
  2079.  
  2080.                         if(Node->Current != *MsgCode || Node != Handle->ClickObject)
  2081.                         {
  2082.                             CurrentTime(&Handle->ClickSeconds,&Handle->ClickMicros);
  2083.  
  2084.                             Handle->ClickObject = Node;
  2085.                         }
  2086.                         else
  2087.                         {
  2088.                             ULONG Seconds,Micros;
  2089.  
  2090.                             CurrentTime(&Seconds,&Micros);
  2091.  
  2092.                             if(DoubleClick(Handle->ClickSeconds,Handle->ClickMicros,Seconds,Micros))
  2093.                                 *MsgClass = IDCMP_IDCMPUPDATE;
  2094.  
  2095.                             Handle->ClickSeconds    = Seconds;
  2096.                             Handle->ClickMicros    = Micros;
  2097.                         }
  2098.  
  2099.                         Node->Current = *MsgCode;
  2100.  
  2101.                         LTP_PutStorage(Node);
  2102.  
  2103.                         if(Node->Special.List.AutoPageID != -1)
  2104.                             *MsgClass = NULL;
  2105.  
  2106.                         if(!LTP_NotifyPager(Handle,Node->Special.List.AutoPageID,Node->Current))
  2107.                             *MsgClass = IDCMP_CLOSEWINDOW;
  2108.  
  2109.                         if(Node->Special.List.Link)
  2110.                         {
  2111.                             Handle->Previous = Node->Special.List.Link;
  2112.  
  2113.                             if(!Node->PageSelector)
  2114.                                 Activate = TRUE;
  2115.                         }
  2116.                         else
  2117.                         {
  2118.                             if(Handle->Previous && !Node->PageSelector)
  2119.                                 Activate = TRUE;
  2120.                         }
  2121.  
  2122.                         break;
  2123.  
  2124.                     default:
  2125.  
  2126.                         if(Handle->Previous && !Node->PageSelector)
  2127.                             Activate = TRUE;
  2128.  
  2129.                         break;
  2130.                 }
  2131.             }
  2132.  
  2133.             break;
  2134.  
  2135.         case IDCMP_MOUSEMOVE:
  2136.  
  2137.             #ifdef DO_LEVEL_KIND
  2138.             {
  2139.                 if(Handle->CurrentLevel)
  2140.                     Node = Handle->CurrentLevel;
  2141.                 else
  2142.                     GETOBJECT((*MsgGadget),Node);
  2143.             }
  2144.             #else
  2145.             {
  2146.                 GETOBJECT((*MsgGadget),Node);
  2147.             }
  2148.             #endif /* DO_LEVEL_KIND */
  2149.  
  2150.             if(Node)
  2151.             {
  2152.                 if(Node->Type != LISTVIEW_KIND)
  2153.                     Handle->ClickSeconds = Handle->ClickMicros = 0;
  2154.  
  2155.                 switch(Node->Type)
  2156.                 {
  2157.                     case SCROLLER_KIND:
  2158.  
  2159.                         Node->Current = *MsgCode;
  2160.  
  2161.                         LTP_PutStorage(Node);
  2162.  
  2163.                         break;
  2164.  
  2165.                     case SLIDER_KIND:
  2166.  
  2167.                         if(Node->Min < 0)
  2168.                             Node->Current = (WORD)*MsgCode;
  2169.                         else
  2170.                             Node->Current = *MsgCode;
  2171.  
  2172.                         LTP_PutStorage(Node);
  2173.  
  2174.                         break;
  2175.  
  2176.                     #ifdef DO_LEVEL_KIND
  2177.                     {
  2178.                         case LEVEL_KIND:
  2179.  
  2180.                             Node->Current = LTP_GetCurrentLevel(Node);
  2181.  
  2182.                             *MsgCode    = Node->Current;
  2183.                             *MsgGadget  = Node->Host;
  2184.  
  2185.                             LTP_PutStorage(Node);
  2186.  
  2187.                             LTP_LevelGadgetDrawLabel(Handle,Node,FALSE);
  2188.  
  2189.                             break;
  2190.                     }
  2191.                     #endif    /* DO_LEVEL_KIND */
  2192.                 }
  2193.             }
  2194.  
  2195.             break;
  2196.  
  2197.         case IDCMP_ACTIVEWINDOW:
  2198.  
  2199.             if(Handle->Previous)
  2200.             {
  2201.                 Activate = TRUE;
  2202.  
  2203.                 *MsgClass    = IDCMP_GADGETDOWN;
  2204.                 *MsgCode    = 0;
  2205.                 *MsgGadget    = Handle->Previous;
  2206.             }
  2207.  
  2208.             break;
  2209.  
  2210.         case IDCMP_INACTIVEWINDOW:
  2211.  
  2212.             Handle->ActiveIncrementer = NULL;
  2213.             Handle->ActiveFrame = NULL;
  2214.             break;
  2215.     }
  2216.  
  2217.     if(Handle->AutoActivate && Activate && Handle->Previous)
  2218.     {
  2219.         if(GETOBJECT(Handle->Previous,Node))
  2220.         {
  2221.             if(!Node->Disabled)
  2222.             {
  2223.                 if(Node->Type == BOOPSI_KIND)
  2224.                 {
  2225.                     if(Node->Special.BOOPSI.ActivateHook)
  2226.                         CallHookPkt(Node->Special.BOOPSI.ActivateHook,(APTR)Handle,(APTR)Node->Host);
  2227.                 }
  2228.                 else
  2229.                     ActivateGadget(Handle->Previous,Handle->Window,NULL);
  2230.             }
  2231.         }
  2232.     }
  2233. }
  2234.